<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>员工管理</title>
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<link rel="stylesheet" href="css/membership.css">
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/vant.css">
    <script src="js/fontsize.js"></script>
    <script src="js/vue/vue.js"></script>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script src="js/vue/axios.js"></script>
    <script src="js/jquery.md5.js"></script>
    <script src="js/vue/vant.js"></script>
	<script src="js/flexible.js"></script>
	<script src="js/vue/qs.js"></script>
	<script src="js/fontsize.js"></script>
	<style>
		.container_box{
			font-size: 0.14rem;
		}
	</style>
</head>
<body>
	<div class="container_box" id="app">
		<header>
			<div class="search bar3">
				<form @submit.prevent action="#">
					<input @keyup.enter.native="search" v-model="from.phone" type="search" placeholder="搜索员工姓名/手机号码">
					<button @click="search" type="text"><img src="images/search.png"></button>
				</form>
			</div>
		</header>
		<div class="add_jl">
			<a href="addStaff.html?type=1"><img src="images/add_customer.png"></a>
		</div>
		<template>
			<div v-for="item in listData" class="group_details group_details_state clearfix">
				<div class="fl head_card">
					<img :src="item.Picurl" onerror="this.src='images/moren.png'" class="spinning_img">
				</div>
				<div class="spinning_txt fl" style="width:78%">
					<p class="margin_bottom">
						<span>{{item.Sname}}</span>
						<span class="vcenter_img">
							<img src="images/women.png" v-if="item.Sex=='0'" style="width: 0.15rem;height: 0.15;">
							<img src="images/man.png" v-else style="width: 0.15rem;height: 0.15;">
						</span>
						<span class="spinning_txx rf">{{item.Rname}}</span>
					</p>
					<p style="margin-bottom: 0.1rem;">
						<!-- <span class="spinning_name">17690821390</span> -->
						<span class="font_size12 rf">
							<!-- <span class="notUse">停用</span> -->
							<span class="record" @click="record(item.id, item.Sname)">销售记录</span>
							<span class="modify" @click="modify(item.id)">修改</span>
							<!-- <span class="yg_delete">删除</span> -->
						</span>
					</p>
				</div>
			</div>
			<van-list
				v-model="loading"
				:finished="finished"
				finished-text="没有更多了"
				@load="getList"
				>
				<van-cell
					v-for="item in lists"
					:key="item"
					:title="item"
				/>
			</van-list>
		</template>
	</div>
</body>
<script>
var app = new Vue({
	el: '#app',
	data: {
		//员工列表
		listData:[],
		from:{
			phone:'',
			page:'1'
		},
		lists:[],
		loading: false,
		finished: false,
		totalnum:'',
		totalpage:'',
		listd:[]
		
	},
	methods: {
		//获取员工列表
		getList(){
			const params=this.from
			axios.get('mobileapi/boss/staff.php?act=staff_list',{params:params}).then(res => {
				let { msg, code} = res.data
					if (code !== 200) {
						vant.Toast('请求发送失败，请重试')
					} else {
						data=res.data
						console.log(data);
						this.listd=data.data.staff_list
						this.totalnum=data.data.totalnum
						this.from.page=parseInt(data.data.page)+1
						for(let i in this.listd){
							if(this.listd[i].Picurl==""||this.listd[i].Picurl==null){
								this.listd[i].Picurl='images/moren.png'
							}
						}
						console.log(this.listd);
						for (let i = 0; i < this.listd.length; i++) {
							this.listData.push(this.listd[i])
						}
						console.log(this.listData);
						// 加载状态结束
						this.loading = false
						// 数据全部加载完成
						if (this.listData.length >= this.totalnum) {
							this.finished = true
						}
					}
				}).catch(err => {
					vant.Toast('请求发送失败，请重试');
				})
			},
		//修改按钮
		modify(id){
			location.href = "addStaff.html?id="+id+"&type=2";
		},
		record(id, name){

			location.href = "salesRecord.html?id="+id + "&name=" + name;
		},
		//搜索
		search(){
			this.listData=[]
			this.lists=[]
			this.listd=[]
			this.from.page='1'
			this.getList()
		}
	},
})
</script>
</html>